package org.swan.web.configuration;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import javax.sql.DataSource;
@Configuration
public class MybatisConfiguration {
    final ApplicationContext applicationContext;

    public MybatisConfiguration(ApplicationContext applicationContext) {
        this.applicationContext = applicationContext;
    }

//    @Bean
//    @ConfigurationProperties(prefix = "db.datasource.hikari.mysql")
//    public DataSource dataSourceOne() {
//        return DataSourceBuilder.create().build();
//    }
//
    @Primary
    @Bean(name = "dataSource_pg")
    @ConfigurationProperties(prefix = "db.datasource.hikari.pg")
    public DataSource dataSourceTwo() {
        return DataSourceBuilder.create().build();
    }
}
